package org.coderjonny.service.fallback.factory;

import feign.hystrix.FallbackFactory;
import org.coderjonny.bean.Product;
import org.coderjonny.dto.Request;
import org.coderjonny.dto.Result;
import org.coderjonny.dto.product.ProductId;
import org.coderjonny.dto.product.UpdateStock;
import org.coderjonny.feign.ProductService;
import org.springframework.stereotype.Component;


@Component
public class ProductServiceFallbackFactory implements FallbackFactory<ProductService> {
    @Override
    public ProductService create(Throwable cause) {
        return new ProductService() {
            @Override
            public Result<Product> getByProductId(Request<ProductId> request) {
                return Result.error("熔断降级Produc");
            }

            @Override
            public Result<String> updateStockById(Request<UpdateStock> request) {
                return Result.error("更新库存失败，熔断降级");
            }
        };
    }
}
